//
//  SLDeployGoodsCollectionViewCell.m
//  StarLight
//
//  Created by Duke.wu on 16/5/31.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//

#import "SLDeployGoodsCollectionViewCell.h"

@interface SLDeployGoodsCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *goodsNameLb;
@property (weak, nonatomic) IBOutlet UILabel *timeLb;
@property (weak, nonatomic) IBOutlet UILabel *startLocLb;
@property (weak, nonatomic) IBOutlet UILabel *finalLocLb;
@property (weak, nonatomic) IBOutlet UILabel *weightLb;
@property (weak, nonatomic) IBOutlet UILabel *finalTimeLb;
@property (weak, nonatomic) IBOutlet UIButton *MathBtn;
@property (weak, nonatomic) IBOutlet UIButton *reFreshBtn;
@property (nonatomic, strong) SLDeployGood *goodsModel;

@end



@implementation SLDeployGoodsCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
  self.backgroundColor = [UIColor whiteColor];
  self.layer.cornerRadius = 5;
  self.MathBtn.layer.cornerRadius = 5;
  [self.MathBtn setTitleColor:SLYellowColor forState:UIControlStateNormal];
  self.MathBtn.titleLabel.font = [UIFont boldSystemFontOfSize:20];
  self.goodsNameLb.textColor = SLYellowColor;
  [self.MathBtn addTarget:self action:@selector(recomendAction) forControlEvents:UIControlEventTouchUpInside];
  [self.reFreshBtn addTarget:self action:@selector(refreshAction) forControlEvents:UIControlEventTouchUpInside];
  [self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self.goodsNameLb);
    make.left.equalTo(self.mas_centerX);
  }];
  
    // Initialization code
}


- (void)configDepolyGoodsCellWith:(SLDeployGood *)model{
  self.goodsModel = model;
  self.goodsNameLb.text = model.hwmc;
  self.weightLb.text = model.hwzw;
  self.timeLb.text = model.time;
  self.startLocLb.text = model.qsgk;
  self.finalLocLb.text = model.ddgk;
  self.finalTimeLb.text = model.jzrq;
  [self.MathBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.matchs] forState:UIControlStateNormal];
  
}


- (void)refreshAction{
  
  if (_delegate && [_delegate respondsToSelector:@selector(cellRefreshBtnWasTaped:)]) {
    [_delegate cellRefreshBtnWasTaped:self.goodsModel];
  }
}

- (void)recomendAction{
  if (self.goodsModel.matchs == 0) {
    [SVProgressHUD showImage:nil status:@"没有推荐船舶"];
  }else{
    if (_delegate && [_delegate respondsToSelector:@selector(cellRecomendBtnWasTaped:)]) {
      [_delegate cellRecomendBtnWasTaped:self.goodsModel];
    }
  }
  
}



@end
